<?
require("required/dbconnect.php");
if (empty($_SESSION['order_id'])) {
    header("Location:os_invalid.php?error=3");
}
require("required/share_function.php");

$title = "Order Sent ";
require("required/header.php");

$get_payment_setting = mysql_query("select ebank_allowed,cc_allowed,paypal_allowed from os_contactinfo where id=1");
$allowed = mysql_fetch_array($get_payment_setting, MYSQL_ASSOC);
?>
<script language="JavaScript" type="text/javascript" src="required/js/goAjax.js"></script>
<script language="javascript">
    function getRadio(name,frmName) {
        var f = eval('document.'+frmName);
				
        if(!f[name].length){ //only one checkbox
            if(!f[name].checked){
                return -1;
            }else{
                return f[name].value;		
            }
					
        }else{
				
            for (i=0; i<f[name].length; i++)
                if (f[name][i].checked) return f[name][i].value;
        }
    }
			
    function frmValidate(frm1){
				
        var paymethod = getRadio("paymethod", "frm1");
        var msg="";
        if(paymethod==1)
        {
            msg="You have choose to pay by e-banking, confirm to continue?";
        }else{
            msg="You have choose to pay by Paypal / Credit Card, confirm to continue?";
        }
					
        if(!confirm(msg))
        {
            return false;
        }			
				
    }
			
    function submitForm()
    {
        document.frm1.submit();
    }
</script>
<table width="100%">
    <tr>
        <td class='page_title_bar'>
            Confirm Order
        </td>					
    </tr>
    <tr>
        <Td height="400" valign="top" >
            <table width="80%" align="center" class="success">
                <td colspan="2">

                    <form method="post" action="os_paymentmethod.php" name="frm1" onSubmit="return frmValidate(this)">
                        <input type="hidden" name="id" value="<?= $_SESSION['order_id'] ?>">
                        <?
                        if ($allowed['paypal_allowed'] == 1 && $allowed['ebank_allowed'] == 1) {
                            ?>
                            <div class="dw_success">Your order has been confirmed, Please choose your payment method.</div>
                            <input type="radio" name="paymethod" value="1" checked> Pay via E-Banking<br><br>
    <?
    if ($allowed['paypal_allowed'] == 1) {
        $paypal_disable = "";
        $pp_msg = "";
    } else {
        $paypal_disable = "disabled";
        $pp_msg = "<font color='red'><i>(temporary not available)</i></font>";
    }
    ?>
                            <input type="radio" name="paymethod" value="3" <?= $paypal_disable ?>> Pay via <img src="images/p1.gif"> <?= $pp_msg ?>
                            <?
                        } else {

                            if ($allowed['paypal_allowed'] == 1) {
                                $paymethod = "3";
                            } else {
                                $paymethod = "1";
                            }
                            ?>

                            <input type="hidden" name="paymethod" value="<?= $paymethod ?>" />
                            <script language="javascript">
                                submitForm();
                            </script>
                        <? } ?>

                        <br><br>
                        <div align="center"><input type="submit" value="Submit" class="button" name="btnsubmit"></div>
                    </form>

                </td>


            </table>
        </td>
    </tr>

</table>


<? require("required/footer.php"); ?>	